/*Copyright (C) 2013-2020 LZE*/
#include<bits/stdc++.h>
#define INF 0x7f7f7f7f
using namespace std;
typedef long long ll;
int n;
inline int rd() {
	int x=0;bool ntv=false;char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();if(c=='-')ntv=true;else x=(c^48);c=getchar();
	while(c>='0'&&c<='9') {x=x*10+(c^48);c=getchar();}return ntv?-x:x;
}
struct link{
	int data;
	link *next;
};
int main() {
	n=rd();
	link *head,*tail,*tmp;
	head=new(link);
	tail=head;
	while(n!=-1){
		tmp=new(link);
		tmp->data=n;
		tmp->next=NULL;
		tail->next=tmp;
		tail=tmp;
		cin>>n;
	}
	tmp=head->next;
	while(tmp!=NULL){
		cout<<tmp->data<<" ";
		tmp=tmp->next;
	}
	return 0;
}
//5 4 3 2 1 -1
